#include "mainwindow.h"

Widget::Widget(QWidget *parent) :
    QGraphicsView(parent)
{
    scene = new QGraphicsScene(this);
    scene->setSceneRect(0,0, this->width(), this->height());
    setScene(scene);

}

Widget::~Widget() {
    delete scene;
}

void Widget::mousePressEvent(QMouseEvent* pe){
    if (pe->button() == Qt::LeftButton){
        drowSquare(pe->pos());
    }
    else if (pe->button() == Qt::RightButton){
        drowCircle(pe->pos());
    }
}
void Widget::drowSquare(const QPoint & pos){
     scene->addRect(pos.x(), pos.y(), 30, 30,QPen(Qt::red, 1, Qt::SolidLine));

}

void Widget::drowCircle(const QPoint & pos){
    scene->addEllipse(pos.x(), pos.y(), 20, 20,QPen(Qt::blue, 1, Qt::SolidLine));
}
